﻿package mortal.game.view.lotteryDraw
{
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import flash.text.*;
    import mortal.common.global.*;
    import mortal.game.manager.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.tooltip.tool.*;

    public class lotteryDrawRecordRewardItemCellRender extends GCellRenderer
    {
        private var _itemTxt:GTextFiled;
        private var _otherTxt:GTextFiled;
        private var _itemData:ItemData;

        public function lotteryDrawRecordRewardItemCellRender()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:* = GlobalStyle.textFormatBai;
            _loc_1.underline = true;
            this._itemTxt = UIFactory.gTextField("", 0, 0, 100, 20, this, _loc_1);
            this._itemTxt.autoSize = TextFieldAutoSize.LEFT;
            this._otherTxt = UIFactory.gTextField("", 0, 0, 100, 20, this);
            this._otherTxt.autoSize = TextFieldAutoSize.LEFT;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this.removeListener();
            this._itemTxt.dispose(param1);
            this._itemTxt = null;
            this._otherTxt.dispose(param1);
            this._otherTxt = null;
            this._itemData = null;
            super.disposeImpl(param1);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            super.data = param1;
            var _loc_2:String = "";
            var _loc_3:* = param1 as lotteryDrawRecordRewardItemDataGroup;
            if (_loc_3.itemCode > 0)
            {
                this._itemData = new ItemData(_loc_3.itemCode);
                this._itemTxt.htmlText = ItemsUtil.getItemName(this._itemData);
                this.addListener();
                _loc_2 = "x" + String(_loc_3.itemAmout);
            }
            else if (_loc_3.money != 0)
            {
                this._itemTxt.text = "";
                if (_loc_3.money > 0)
                {
                    _loc_2 = Language.getStringByParam(90446, String(_loc_3.money), _loc_3.diaPt);
                }
                else
                {
                    _loc_4 = Math.abs(_loc_3.money);
                    _loc_5 = _loc_4 * 0.2;
                    _loc_2 = "钻石" + String(_loc_4) + "(" + String(_loc_3.diaPt) + "%)+<font color=\'#ffff00\'>" + String(_loc_5) + "</font>";
                }
            }
            if (_loc_3.signType == 1)
            {
                _loc_2 = _loc_2 + Language.getString(90447);
            }
            this._otherTxt.htmlText = _loc_2;
            this._otherTxt.x = this._itemTxt.x + this._itemTxt.width;
            this.setSize(this._itemTxt.width + this._otherTxt.width, this.height);
            return;
        }// end function

        private function showToolTipHandler(event:MouseEvent) : void
        {
            var _loc_2:* = this._itemData;
            ItemClickToolTipUtil.showClickToolTip(event.stageX, event.stageY, _loc_2);
            return;
        }// end function

        private function addListener() : void
        {
            this._itemTxt.addEventListener(MouseEvent.CLICK, this.showToolTipHandler);
            this._itemTxt.addEventListener(MouseEvent.MOUSE_OVER, this.mouseStyleHandler);
            this._itemTxt.addEventListener(MouseEvent.MOUSE_OUT, this.mouseStyleHandler);
            return;
        }// end function

        private function removeListener() : void
        {
            this._itemTxt.removeEventListener(MouseEvent.CLICK, this.showToolTipHandler);
            this._itemTxt.removeEventListener(MouseEvent.MOUSE_OVER, this.mouseStyleHandler);
            this._itemTxt.removeEventListener(MouseEvent.MOUSE_OUT, this.mouseStyleHandler);
            return;
        }// end function

        private function mouseStyleHandler(event:MouseEvent) : void
        {
            if (event.type == MouseEvent.MOUSE_OVER)
            {
                CursorManager.showCursor(CursorManager.BUTTON);
            }
            if (event.type == MouseEvent.MOUSE_OUT)
            {
                CursorManager.hideCursor();
            }
            return;
        }// end function

    }
}
